<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Uploader全部方法demo</title>
<script src="http://g.tbcdn.cn/kissy/k/1.4.2/seed-min.js" charset="utf-8"></script>
</head>
<body>
    <h2>Uploader全部方法demo</h2>
    <div class="grid">
        <input type="file" class="g-u" id="J_UploaderBtn" value="上传文件" name="Filedata" >
        <input type="hidden" id="J_Urls" name="urls" value="" />
    </div>
    <ul id="J_UploaderQueue">

    </ul>
    <div class="btn-wrapper">
        <input id="J_Upload" type="button" value="上传第一个文件">
        <input id="J_UploadFiles" type="button" value="上传所有等待中的文件">
        <input id="J_Cancel" type="button" value="取消正在文件的上传">
        <input id="J_Stop" type="button" value="停止上传">
    </div>
<script>
    var S = KISSY, $ = S.Node.all;
    if (S.Config.debug) {
        var srcPath = "../../../../";
        S.config({
            packages:[
                {
                    name:"gallery",
                    path:srcPath,
                    charset:"utf-8"
                }
            ]
        });
    }

    S.use('gallery/uploader/1.5.4/index,gallery/uploader/1.5.4/themes/default/index,gallery/uploader/1.5.4/themes/default/style.css', function (S, Uploader,DefaultTheme) {
        //上传组件插件
        var plugins = 'gallery/uploader/1.5.4/plugins/auth/auth,' +
                'gallery/uploader/1.5.4/plugins/urlsInput/urlsInput,' +
                'gallery/uploader/1.5.4/plugins/proBars/proBars';

        S.use(plugins,function(S,Auth,UrlsInput,ProBars){
            var uploader = new Uploader('#J_UploaderBtn',{
                //处理上传的服务器端脚本路径
                action:"upload.php",
                autoUpload:false
            });
            //使用主题
            uploader.theme(new DefaultTheme({
                queueTarget:'#J_UploaderQueue'
            }))
            //验证插件
            uploader.plug(new Auth({
                        //最多上传个数
                        max:3,
                        //图片最大允许大小
                        maxSize:100
                    }))
                //url保存插件
                    .plug(new UrlsInput({target:'#J_Urls'}))
                //进度条集合
                    .plug(new ProBars())
            ;

            $('#J_Upload').on('click',function(){
                uploader.upload(0);
            });
            $('#J_UploadFiles').on('click',function(){
                uploader.uploadFiles('waiting');
            });
            $('#J_Cancel').on('click',function(){
                uploader.cancel();
            });
            $('#J_Stop').on('click',function(){
                uploader.stop();
            });
        });
    })
</script>
</body>
</html>
